package com.dkm.orproject.dkmoa.service.serviceimpl;

import com.dkm.orproject.dkmoa.dao.OaSupplierMapper;
import com.dkm.orproject.dkmoa.domain.OaSupplier;
import com.dkm.orproject.dkmoa.service.OaSupplierService;
import com.dkm.orproject.utils.utils.IdToobtainUtils;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 *  @ClassName : OaSupplierServiceImpl  //供应商服务层实现类名
 *  @Description : OaSupplierService的实现类 //描述
 *  @Author : zmh //作者
 *  @Date: 2020-11-25 16:28  //时间
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class OaSupplierServiceImpl implements OaSupplierService {

    /**
     * id生成工具类
     */
    @Resource
    IdToobtainUtils toobtainUtils;

    /**
     * 供应商mapper对象
     */
    @Resource
    OaSupplierMapper oaSupplierMapper;


    /**
     * 根据Id删除该条供应商类型对象
     *
     * @param pkSupplierId
     * @return 删除的条数
     */
    @Override
    public int deleteByPrimaryKey(Long pkSupplierId) {
        return oaSupplierMapper.deleteByPrimaryKey(pkSupplierId);
    }

    /**
     * 插入一条供应商
     *
     * @param oaSupplier 供应商对象
     * @return 回调函数
     */
    @Override
    public int insertSelective(OaSupplier oaSupplier) {
        oaSupplier.setPkSupplierId(toobtainUtils.getNumberId());
        return oaSupplierMapper.insertSelective(oaSupplier);
    }

    /**
     * 根据pkSupplierId查询供应商对象
     *
     * @param pkSupplierId
     * @return 供应商类型对象
     */
    @Override
    public OaSupplier selectByPrimaryKey(Long pkSupplierId) {
        return oaSupplierMapper.selectByPrimaryKey(pkSupplierId);
    }

    /**
     * 根据oaSupplier的id值修改
     *
     * @param oaSupplier
     * @return 回调函数
     */
    @Override
    public int updateByPrimaryKeySelective(OaSupplier oaSupplier) {
        return oaSupplierMapper.updateByPrimaryKeySelective(oaSupplier);
    }

    /**
     * 供应商总条数
     *
     * @param oaSupplier 供应商对象
     * @param startTime  开始时间
     * @param endTime    结束时间
     * @return 回调函数
     */
    @Override
    public Long rowCount(OaSupplier oaSupplier, String startTime, String endTime) {
        return oaSupplierMapper.rowCount(oaSupplier,startTime,endTime);
    }

    /**
     * 分页查询所有供应商信息
     *
     * @param oaSupplier
     * @param startTime  开始时间
     * @param endTime    结束时间
     * @param page       当前页数
     * @param limit      显示的行数
     * @return 所有规则制度类型对象的集合
     */
    @Override
    public List<OaSupplier> selectAll(OaSupplier oaSupplier, String startTime, String endTime, Integer page, Integer limit) {
        PageHelper.startPage(page,limit);
        return oaSupplierMapper.selectAll(oaSupplier,startTime,endTime);
    }

    /**
     * 供应商类型批量删除
     *
     * @param list list里存入id的集合
     * @return 回调函数
     */
    @Override
    public int deleteAll(List<Long> list) {
        return oaSupplierMapper.deleteAll(list);
    }
}
